package com.concorrency.learn.service;

import com.concorrency.learn.model.Student;
import org.springframework.stereotype.Service;


/**
 * Created by corey on 2018/9/8.
 */
@Service
public class UserService {

    public Student getUserInfo(int id){
        Student student;

        if (id == 1) {
            student = new Student("coreyjk", 18);
        }else{
            student = new Student("未知用户", 0);
        }
        try {
            long time = (long) (Math.random() * 10000);
            Thread.sleep(time);
            System.out.println(Thread.currentThread().getName()+"，getUserInfo沉睡了"+time+"毫秒");
        } catch (InterruptedException e) {
        }
            return student;
    }
}
